package com.example.mydemo.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.example.mydemo.entity.SysParam;
import com.example.mydemo.entity.UserRole;
import com.example.mydemo.entity.domain.UserRoleVO;
import com.example.mydemo.mapper.DepMapper;
import com.example.mydemo.mapper.UserRoleMapper;
import com.example.mydemo.service.IUserRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author syf
 * @since 2025-05-28
 */
@Service
public class UserRoleServiceImpl extends ServiceImpl<UserRoleMapper, UserRole> implements IUserRoleService {
    @Autowired
    private UserRoleMapper userRoleMapper;
    public List<UserRoleVO> selectByUserName(String name) {
        return userRoleMapper.selectByUserName(name);
    }
    public List<UserRoleVO> selectName() {
        return userRoleMapper.selectName();
    }
    public void delete(Long id){
        UserRole userRole = new UserRole();
        userRole.setIsDelete(1L);
        userRoleMapper.update(
                userRole,
                new UpdateWrapper<UserRole>().eq("id", id));
    }
    public void saveUser(UserRoleVO userRoleVO){
        UserRole userRole = new UserRole();
        userRole.setUserId(userRoleVO.getUserId());
        userRole.setRoleId(userRoleVO.getRoleId());
        userRole.setCreateBy(userRoleVO.getCreateBy());
        userRole.setCreateTime(userRoleVO.getCreateTime());
        userRoleMapper.insert(userRole);
    }
}
